package com.sale.salesystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sale.salesystem.entity.DataSource;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
public interface DataSourceMapper extends BaseMapper<DataSource> {
    
    @Select("SELECT ds.*, GROUP_CONCAT(ct.value) as supportedChartTypes " + 
            "FROM data_source ds " +
            "JOIN data_source_chart_type dsct ON ds.id = dsct.data_source_id " +
            "JOIN chart_type ct ON dsct.chart_type_id = ct.id " +
            "GROUP BY ds.id")
    List<Object[]> selectDataSourcesWithChartTypes();
    
    @Select("SELECT ct.value FROM data_source ds " +
            "JOIN data_source_chart_type dsct ON ds.id = dsct.data_source_id " +
            "JOIN chart_type ct ON dsct.chart_type_id = ct.id " +
            "WHERE ds.value = #{dataSourceValue}")
    List<String> selectSupportedChartTypesByDataSource(String dataSourceValue);
} 